package com.ruoyi.logistic.domain;

import com.github.pagehelper.Page;
import lombok.Data;

import java.io.Serializable;
import java.util.List;

@Data
public class PageInfo <T> implements Serializable {
    private static final long serialVersionUID = 7424228537400278127L;
    private T data;
    private Integer current;
    private Long total;
    private Integer pages;

    private PageInfo(){

    }
    public static Object info(List list){
        if( !(list instanceof  Page)){
            return  list;
        }
        Page page = (Page) list;
        PageInfo pageInfo = new PageInfo();
        pageInfo.setData(page);
        pageInfo.setCurrent(page.getPageNum());
        pageInfo.setTotal(page.getTotal());
        pageInfo.setPages(page.getPages());
        return pageInfo;
    }

}